from model import BaseModel, models
from menu.models import Menus


class Roles(BaseModel):
    name = models.CharField(max_length=32, unique=True, verbose_name="角色名")

    class Meta:
        db_table = 'roles'
        verbose_name = '角色信息'
        verbose_name_plural = verbose_name


class RoleToMenu(models.Model):
    role = models.ForeignKey(to=Roles, on_delete=models.CASCADE)
    menu = models.ForeignKey(to=Menus, on_delete=models.CASCADE)

    class Meta:
        db_table = 'role_to_menu'
        verbose_name = '角色菜单'
        verbose_name_plural = verbose_name
